package magicboard.model
{
  import flash.display.Shape;
  import flash.geom.Point;
  
  import flexunit.framework.TestCase;
  import flexunit.framework.TestSuite;
  
  public class StrokeTestCase extends TestCase
  {
    // --------------------------------------------------------------------------------------------	
    public function StrokeTestCase(methodName:String) {
   	 super( methodName );
    }

    // --------------------------------------------------------------------------------------------	
    public static function suite():TestSuite {
   			var ts:TestSuite = new TestSuite();
   			
   			ts.addTest( new StrokeTestCase( "testSave" ) );
   			ts.addTest( new StrokeTestCase( "testLoad" ) );
   			ts.addTest( new StrokeTestCase( "testDrawEmpty" ) );
   			ts.addTest( new StrokeTestCase( "testBox" ) );
   			return ts;
   		}

  
    // --------------------------------------------------------------------------------------------
		public function testLoad():void {
    	var stroke:InkStroke = new InkStroke();
    	
    	stroke.loadFromString("abc: (1,2), (3,4)");
 			assertEquals("abc", stroke.type );
 			assertEquals(1, stroke.points[0].x );
 			assertEquals(2, stroke.points[0].y );
 			assertEquals(3, stroke.points[1].x );
 			assertEquals(4, stroke.points[1].y );
 		}
  		
    // --------------------------------------------------------------------------------------------
		public function testSave():void {
      var stroke:InkStroke = new InkStroke();
      var text:String;
      
      stroke.addPoint(new Point(1234, 5678));
      text = stroke.saveToString();
       			
 			assertTrue(text.indexOf("1234") > 0);
 			assertTrue(text.indexOf("5678") > 0);
 		}
  		
    // --------------------------------------------------------------------------------------------
		public function testDrawEmpty():void {
      var stroke:InkStroke = new InkStroke();
      var shape:Shape = new Shape();
      
      stroke.draw(shape.graphics); 			
 		}
  		
    // --------------------------------------------------------------------------------------------
		public function testBox():void {
    	var stroke:InkStroke = new InkStroke();
    	
    	stroke.loadFromString("abc: (1,2), (3,4), (34, 56), (13, 4)");

 			assertEquals(1, stroke.boundingBox.left );
 			assertEquals(34, stroke.boundingBox.right );
 			assertEquals(2, stroke.boundingBox.top );
 			assertEquals(56, stroke.boundingBox.bottom );
 		}
  		
 		
 	}
}